<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="统一设置" name="first">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>抽成比例设置</span>
            <el-button
              style="float: right; padding: 5px 10px"
              type="primary"
              @click="submitScale()"
            >保存</el-button>
          </div>
          <el-form :label-position="labelPosition" label-width="250px" :model="scaleSet">
            <el-form-item label="VIP一级抽成比例（%）:">
              <el-input-number
                style="width:125px"
                controls-position="right"
                v-model="scaleSet.buyCourseL1Ratio"
                :min="0"
                :max="99"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="VIP推vip一次性抽成（%）:">
              <el-input-number
                style="width:125px"
                controls-position="right"
                v-model="scaleSet.upgradeMembershipL1Ratio"
                :min="0"
                :max="99"
              ></el-input-number>%
            </el-form-item>
            <!-- <el-form-item label="VIP商品折扣:">
              <el-input-number
                style="width:125px"
                controls-position="right"
                v-model="scaleSet.buyDiscount"
                :min="0"
                :max="10"
              ></el-input-number>%
            </el-form-item> -->
            <el-form-item label="合伙人一级抽成比例（%）:">
              <el-input-number
                style="width:125px"
                controls-position="right"
                v-model="scaleSet.partnerDiscount"
                :min="0"
                :max="99"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="运营中心一级抽成比例（%）:">
              <el-input-number
                style="width:125px"
                controls-position="right"
                v-model="scaleSet.runDiscount"
                :min="0"
                :max="99"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="分公司一级抽成比例（%）:">
              <el-input-number
                style="width:125px"
                controls-position="right"
                v-model="scaleSet.companyDiscount"
                :min="0"
                :max="99"
              ></el-input-number>%
            </el-form-item>
          </el-form>
        </el-card>

        <el-card>
          <div slot="header" class="clearfix">
            <span>代理商设置</span>
            <el-button
              type="primary"
              style="float: right; padding: 5px 10px"
              @click="submitScale()"
            >保存</el-button>
          </div>
          <el-form :label-position="labelPosition" label-width="380px" v-model="scaleSet">
            <p>合伙人设置：</p>
            <el-form-item label="充值金额:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.partnerMoney"
                controls-position="right"
              ></el-input-number>元
            </el-form-item>
            <el-form-item label="赠送VIP数量:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.partnerNumber"
                controls-position="right"
              ></el-input-number>个
            </el-form-item>
            <el-form-item label="直接推广VIP（用完赠送vip后的分成比例）:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.partnerNumbers"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="协助平台招商（合伙人、运营中心、分公司）一次性分成:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.partnerAssist"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>

            <el-form-item label="旗下vip推vip分成比例:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.partnerVip"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>

            <p>运营中心设置：</p>
            <el-form-item label="充值金额:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.runMoney"
                controls-position="right"
              ></el-input-number>元
            </el-form-item>
            <el-form-item label="赠送VIP数量:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.runMumber"
                controls-position="right"
              ></el-input-number>个
            </el-form-item>
            <el-form-item label="直接推广VIP（用完赠送vip后的分成比例）:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.runMumbers"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="协助平台招商（合伙人、运营中心、分公司）一次性分成:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.runAssist"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="旗下团队推广vip收益比例:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.runDifference"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="旗下vip推vip分成比例:">
              <el-input-number style="width:150px" v-model="scaleSet.runVip" controls-position="right"></el-input-number>%
            </el-form-item>

            <p>分公司设置：</p>
            <el-form-item label="充值金额:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.companyMoney"
                controls-position="right"
              ></el-input-number>元
            </el-form-item>
            <el-form-item label="赠送VIP数量:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.companyNumber"
                controls-position="right"
              ></el-input-number>个
            </el-form-item>
            <el-form-item label="直接推广VIP（用完赠送vip后的分成比例）:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.companyNumbers"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="协助平台招商（合伙人、运营中心、分公司）一次性分成:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.companyAssist"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="旗下团队推广vip收益比例:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.partnerDifference"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>
            <el-form-item label="旗下vip推vip分成比例:">
              <el-input-number
                style="width:150px"
                v-model="scaleSet.companyVip"
                controls-position="right"
              ></el-input-number>%
            </el-form-item>
          </el-form>
        </el-card>
      </el-tab-pane>
      <!-- <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane> -->
    </el-tabs>
  </div>
</template>
<script>
import { proportion, unification } from "@/api/member";
export default {
  data() {
    return {
      activeName: "first",
      labelPosition: "right",

      scaleSet: {
        buyCourseL1Ratio: "",
        upgradeMembershipL1Ratio: "",
        buyDiscount: "",
        partnerDiscount: "",
        runDiscount: "",
        companyDiscount: "",
        partnerMoney: "",
        partnerNumber: "",
        partnerNumbers: "",
        partnerVip: "",
        partnerAssist: "",
        runMoney: "",
        runMumber: "",
        runMumbers: "",
        runVip: "",
        runAssist: "",
        runDifference: "",
        companyMoney: "",
        companyNumber: "",
        companyNumbers: "",
        companyVip: "",
        companyAssist: "",
        partnerDifference: ""
      }
    };
  },
  watch: {
    scaleSetDistribution(val) {
      console.log(val);
    }
  },
  methods: {
    submitScale() {
      unification(this.scaleSet).then(res => {
        console.log(res);
      });
      this.getScale();
    },
    handleClick() {},
    getScale() {
      proportion().then(res => {
        console.log(res);
        var data = res.data.data;
        this.scaleSet = {
          buyCourseL1Ratio: data.buyCourseL1Ratio,
          upgradeMembershipL1Ratio: data.upgradeMembershipL1Ratio,
          // buyDiscount: data.buyDiscount,
          partnerDiscount: data.partnerDiscount,
          runDiscount: data.runDiscount,
          companyDiscount: data.companyDiscount,
          partnerMoney: data.partnerMoney,
          partnerNumber: data.partnerNumber,
          partnerNumbers: data.partnerNumbers,
          partnerVip: data.partnerVip,
          partnerAssist: data.partnerAssist,
          runMoney: data.runMoney,
          runMumber: data.runMumber,
          runMumbers: data.runMumbers,
          runVip: data.runVip,
          runAssist: data.runAssist,
          runDifference: data.runDifference,
          companyMoney: data.companyMoney,
          companyNumber: data.companyNumber,
          companyNumbers: data.companyNumbers,
          companyVip: data.companyVip,
          companyAssist: data.companyAssist,
          partnerDifference: data.partnerDifference
        };
      });
    }
  },
  mounted() {
    this.getScale();
  }
};
</script>
<style scoped>
</style>
